package com.casic.modules.jy.controller;

import java.util.List;
import java.util.Map;
import com.casic.common.utils.R;
import com.casic.common.base.entity.PageEntity;
import com.casic.modules.sys.entity.SysUserEntity;
import com.casic.modules.sys.shiro.ShiroUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.casic.modules.jy.entity.JySjXsEntity;
import com.casic.modules.jy.service.JySjXsService;


/**
 * 学生考试列表待考试和已考完信息
 * 
 * @author mfc
 * @email 123456789@qq.com
 * @date 2018-09-25 14:55:22
 */
@RestController
@RequestMapping("jysjxs")
public class JySjXsController {
	@Autowired
	private JySjXsService jySjXsService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	public R list(@RequestParam Map<String, Object> params){
		SysUserEntity sysUserEntity= ShiroUtils.getUserEntity();
		params.put("userId", sysUserEntity.getUserId());
        PageEntity<JySjXsEntity> page=jySjXsService.findPage(params);
		return R.ok().put("page", page);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	public R info(@PathVariable("id") String id){
		JySjXsEntity jySjXs = jySjXsService.findById(id);
		return R.ok().put("jySjXs", jySjXs);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	public R save(@RequestBody JySjXsEntity jySjXs){
		jySjXsService.save(jySjXs);
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")

	public R update(@RequestBody JySjXsEntity jySjXs){
		jySjXsService.edit(jySjXs);
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	public R delete(@RequestBody String[] ids){
		jySjXsService.removeByIds(ids);
		return R.ok();
	}

	@RequestMapping("/querySjByUser")
	public R querySjByUser(@RequestParam Map<String,Object> param){
		SysUserEntity sysUserEntity = ShiroUtils.getUserEntity();
		param.put("name",sysUserEntity.getUsername());
		List<Map<String,Object>> list = jySjXsService.querySjByUser(param);
		return R.ok().put("list",list);
	}

}
